# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=gd
pkgver=2.3.0
pkgrel=1
_pkgreal=lib$pkgname
pkgdesc="Library for the dynamic creation of images by programmers"
url="https://libgd.github.io/"
arch="all"
license="custom"
makedepends="bash libpng-dev libjpeg-turbo-dev libwebp-dev freetype-dev zlib-dev"
subpackages="$pkgname-dev $_pkgreal:libs"
source="https://github.com/$_pkgreal/$_pkgreal/releases/download/gd-$pkgver/$_pkgreal-$pkgver.tar.xz"
builddir="$srcdir/$_pkgreal-$pkgver"
# https://github.com/libgd/libgd/issues/359
options="!check"

# secfixes:
#   2.3.0-r0:
#     - CVE-2019-11038
#     - CVE-2018-14553
#   2.2.5-r2:
#     - CVE-2018-5711
#     - CVE-2019-6977
#     - CVE-2019-6978
#   2.2.5-r1:
#     - CVE-2018-1000222

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--without-fontconfig \
		--disable-werror
	make
}

check() {
	make check
}

package() {
	DESTDIR="$pkgdir" make install
}

dev() {
	default_dev
	depends="$pkgname perl"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/bdftogd "$subpkgdir"/usr/bin/
}

sha512sums="5b201d22560e147a3d5471010b898ad0268c3a2453b870d1267b6ba92e540cf9f75099336c1ab08217e41827ac86fe04525726bf29ad117e5dcbaef9a8d0622a  libgd-2.3.0.tar.xz"
